
<%@page import="com.netcracker.entity.Country"%>
<%@page import="com.netcracker.entity.User"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%  String path = request.getContextPath();
    User currentUser = (User) request.getAttribute("user");
    List<Country> countries = (List<Country>) request.getAttribute("countries");
%>
<article id="user_info">
    <header class="elem_bground">
        <h1 id="title">
            Редактирование профиля
        </h1>
    </header>
    <section id="info" class="elem_bground">
        <form id="change_info_form" action="<%=path +"?action=changeUserInfo"%>" method="post">
            <table>
                <tr>
                    <th>Логин</th>
                    <td><input type="text" required name="username" size="35"></td>
                </tr>
                <tr>
                    <th>ФИО</th>
                    <td><input type="text" name="fullName" size="35"  required></td>
                </tr>
                <tr>
                    <th>Дата рождения</th>
                    <td><input type="date" name="bDate" required></td>
                </tr>
                <tr>
                    <th>Страна</th>
                    <td>
                        <select size="1" name="countryID" required>
                            <option disabled>Выберите страну</option>
                            <%
                                for (Country currentCountry : countries) {
                                    if (currentCountry.equals(currentUser.getCountry())) {
                            %>
                            <option selected value="<%=currentCountry.getId()%>"><%=currentCountry.getName()%></option>
                            <%
                                }
                            %>
                            <option value="<%=currentCountry.getId()%>"><%=currentCountry.getName()%></option>
                            <%
                                }
                            %>

                        </select>
                    </td>
                </tr>
            </table>
        </form>
    </section>
    <footer>
        <input type="submit" value="ПОДТВЕРДИТЬ" class="button" form="change_info_form">
    </footer>

</article>
<article id="user_password">
    <header class="elem_bground">
        <h1 id="title">
            Смена пароля
        </h1>
    </header>
    <section id="change_password" class="elem_bground">
        <form id="change_pass_form" action="<%=path +"?action=changeUserPass"%>" method="post">
            <table>
                <tr>
                    <th>Старый пароль</th>
                    <td><input type="password" required name="oldPassword" size="35"></td>
                </tr>
                <tr>
                    <th>Новый пароль</th>
                    <td><input type="password" required name="newPassword" size="35" ></td>
                </tr>
                <tr>
                    <th>Повторите пароль</th>
                    <td><input type="password" required name="password2" size="35"></td>
                </tr>

            </table>
        </form>
    </section>
    <footer>
        <input type="submit" value="ПОДТВЕРДИТЬ" class="button" form="change_pass_form">
    </footer>

</article>
